# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.AndroidPublisher.V3.Model.AutoRenewingBasePlanType do
  @moduledoc """
  Represents a base plan that automatically renews at the end of its subscription period.

  ## Attributes

  *   `accountHoldDuration` (*type:* `String.t`, *default:* `nil`) - Optional. Account hold period of the subscription, specified in ISO 8601 format. Acceptable values must be in days and between P0D and P60D. If not specified, the default value is P30D. The sum of gracePeriodDuration and accountHoldDuration must be between P30D and P60D days, inclusive.
  *   `billingPeriodDuration` (*type:* `String.t`, *default:* `nil`) - Required. Immutable. Subscription period, specified in ISO 8601 format. For a list of acceptable billing periods, refer to the help center. The duration is immutable after the base plan is created.
  *   `gracePeriodDuration` (*type:* `String.t`, *default:* `nil`) - Grace period of the subscription, specified in ISO 8601 format. Acceptable values must be in days and between P0D and the lesser of 30D and base plan billing period. If not specified, a default value will be used based on the billing period. The sum of gracePeriodDuration and accountHoldDuration must be between P30D and P60D days, inclusive.
  *   `legacyCompatible` (*type:* `boolean()`, *default:* `nil`) - Whether the renewing base plan is backward compatible. The backward compatible base plan is returned by the Google Play Billing Library deprecated method querySkuDetailsAsync(). Only one renewing base plan can be marked as legacy compatible for a given subscription.
  *   `legacyCompatibleSubscriptionOfferId` (*type:* `String.t`, *default:* `nil`) - Subscription offer id which is legacy compatible. The backward compatible subscription offer is returned by the Google Play Billing Library deprecated method querySkuDetailsAsync(). Only one subscription offer can be marked as legacy compatible for a given renewing base plan. To have no Subscription offer as legacy compatible set this field as empty string.
  *   `prorationMode` (*type:* `String.t`, *default:* `nil`) - The proration mode for the base plan determines what happens when a user switches to this plan from another base plan. If unspecified, defaults to CHARGE_ON_NEXT_BILLING_DATE.
  *   `resubscribeState` (*type:* `String.t`, *default:* `nil`) - Whether users should be able to resubscribe to this base plan in Google Play surfaces. Defaults to RESUBSCRIBE_STATE_ACTIVE if not specified.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :accountHoldDuration => String.t() | nil,
          :billingPeriodDuration => String.t() | nil,
          :gracePeriodDuration => String.t() | nil,
          :legacyCompatible => boolean() | nil,
          :legacyCompatibleSubscriptionOfferId => String.t() | nil,
          :prorationMode => String.t() | nil,
          :resubscribeState => String.t() | nil
        }

  field(:accountHoldDuration)
  field(:billingPeriodDuration)
  field(:gracePeriodDuration)
  field(:legacyCompatible)
  field(:legacyCompatibleSubscriptionOfferId)
  field(:prorationMode)
  field(:resubscribeState)
end

defimpl Poison.Decoder, for: GoogleApi.AndroidPublisher.V3.Model.AutoRenewingBasePlanType do
  def decode(value, options) do
    GoogleApi.AndroidPublisher.V3.Model.AutoRenewingBasePlanType.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.AndroidPublisher.V3.Model.AutoRenewingBasePlanType do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
